package com.example.chengdazhi.slice;

import com.example.chengdazhi.ResourceTable;
import it.chengdazhi.decentbanner.DecentBanner;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.LayoutScatter;

import java.util.ArrayList;
import java.util.List;

public class MainAbilitySlice extends AbilitySlice {
    private DecentBanner decentBanner;
    private List<Component> views;
    private List<String> titles;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        decentBanner = (DecentBanner) findComponentById(ResourceTable.Id_decent_banner);
        Component view1 = LayoutScatter.getInstance(this).parse(ResourceTable.Layout_popular_layout, null, false);
        Component view2 = LayoutScatter.getInstance(this).parse(ResourceTable.Layout_daily_layout, null, false);
        Component view3 = LayoutScatter.getInstance(this).parse(ResourceTable.Layout_recommend_layout, null, false);
        views = new ArrayList<>();
        views.add(view1);
        views.add(view2);
        views.add(view3);

        titles = new ArrayList<>();
        titles.add("POPULAR");
        titles.add("IMAGE");
        titles.add("RECOMMEND");
        decentBanner.start(views, titles, 2, 500, ResourceTable.Media_logo);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
